View Picture is a utility for viewing, cropping, and compressing pictures (if QuickTime is available). It is scriptable and recordable, and supports drag-and-drop (if available) and balloon help. It requires system 7.0 or higher. View Picture uses an intelligent algorithm for cropping pictures that determines how many colors are required and doesn't use a deeper bitmap than necessary.
Please report any bugs (not described in this documentation) to geoffk@ozemail.com.au.
Most of what view picture does is obvious, and there's always balloon help—but you should read the legal information at the end of this document. The only thing that might not be obvious is how to script it:
Scripting View Picture
View Picture fully supports the Core and Required Suites (with one exception relating to selections). It also supports the cut, copy, and paste events, and transactions.
The exception for selections is that selections in View Picture do not contain object specifiers. To get an object specifier for a selection, you use get the contents of selection as reference (or similar to get the selection of a particular document, get the contents of the selection of window 1 as reference—see bugs below). To set the selection, use set the selection to some picture of document 1 or similar.
View Picture also supports a few events and object classes of its own. All of these are fully described in its dictionary (which I've pasted in from Script Editor and put below), except for the way you select picture objects. To get the entire picture of a document, you can write ‘some picture of document 1’ (or send an equivalent event using some other method) but you can also get parts of pictures. AppleScript doesn't support this. From a programming language, you create an object specifier record, with:
keyAEDesiredClass: 'PICT'
keyAEContainer: object specifier records for the picture document or picture that contains this picture
keyAEKeyForm: pBounds
keyAEKeyData: a rectangle, typeRectangle, containing the coordinates than enclose the part of the picture this record is to reference.
This lets you get and copy pictures without having to change the selection (as you would have to to get equivalent functionality from AppleScript).
View Picture suite: Suite for things specific to View Picture
compress: Use QuickTime to compress the picture
compress reference -- the picture to compress
[compressor JPEG/none/graphics/run length encoding] -- the kind of compressor to use; defaults to the user’s settings or jpeg
[quality integer] -- the amount of compression to do (0-1024), or
[quality lossless/maximum/high/normal/low/minimum] -- the amount of compression to do; defaults to the user’s settings or normal
[depth integer] -- the compression depth: 1,2,4,8,16,24,32 for color, 34,36,40 for 2/4/8-bit greyscale, 0 for ‘what the picture asks for’; defaults to the user’s settings or 0
make bitmap: Make a picture into a bitmap
make bitmap reference -- the picture to make into a bitmap
Class about box: The document produced by choosing ‘About…’
Elements:
window by numeric index, by ID, by name, satisfying a test
Properties:
about picture picture [r/o] -- the picture in the box
best type type class [r/o] -- the data type that can contain the most information from objects of this class
class type class [r/o] -- the class of this object
default type type class [r/o] -- the default data type for this object
id integer [r/o] -- the (unique) id number of this object
index integer -- the number of the document
modified boolean [r/o] -- Has the document been modified since the last save?
name string [r/o] -- the name of the document
Class picture document: A document containing a picture
Elements:
window by numeric index, by ID, by name, satisfying a test
picture by numeric index, 'pbnd'
Properties:
best type type class [r/o] -- the data type that can contain the most information from objects of this class
class type class [r/o] -- the class of this object
default type type class [r/o] -- the default data type for this object
id integer [r/o] -- the (unique) id number of this object
index integer -- the number of the document
modified boolean [r/o] -- Has the document been modified since the last save?
name string [r/o] -- the name of the document
Class picture: A QuickDraw picture
Elements:
picture 'pbnd'
Properties:
arcs integer [r/o] -- the number of arcs in this picture
best type type class [r/o] -- the data type that can contain the most information from objects of this class
bitmaps integer [r/o] -- the number of bitmaps in this picture
bounds bounding rectangle [r/o] -- the boundary rectangle for the picture
class type class [r/o] -- the class of this object
comments integer [r/o] -- the number of picture comments in this picture
default type type class [r/o] -- the default data type for this object
depth integer [r/o] -- the maximum number of bits per pixel required for this picture
horizontal resolution fixed [r/o] -- the number of pixels per inch for this picture in the horizontal direction
lines integer [r/o] -- the number of lines in this picture
ovals integer [r/o] -- the number of ovals in this picture
pixmaps integer [r/o] -- the number of pixmaps in this picture
polygons integer [r/o] -- the number of polygons in this picture
rounded rectangles integer [r/o] -- the number of rounded rectangles in this picture
rectangles integer [r/o] -- the number of rectangles in this picture
regions integer [r/o] -- the number of QuickDraw regions in this picture
texts integer [r/o] -- the number of text strings in this picture
complexity unknown/original/color/extended/compressed [r/o] -- an indicator of the complexity of this picture
unique colors integer [r/o] -- the number of different colors in this picture
unique comments integer [r/o] -- the number of different comments in this picture
unique fonts integer [r/o] -- the number of different fonts in this picture
vertical resolution fixed [r/o] -- the number of pixels per inch for this picture in the vertical direction
Known bugs in View Picture:
- view picture doesn't always recognise certain compressed pictures as compressed (because it uses the wrong algorithm to determine if a picture is compressed or not). As well as affecting display of the menus, this can cause problems with cropping and conversion of pictures to bitmaps; view picture can estimate the number of bits per pixel required to be much lower than it should be (for instance, 1 bit, for a partly JPEG-compressed picture).
- saving documents isn't really well thought out; for one thing, the ‘do you want to save’ dialog shouldn't mention the name of a picture if it doesn't have one.
- view picture always zooms a window to the main display, not the display it's currently on.
View picture has been tested under system 7.0.1, 7.1.0 and 7.1.2. There is no reason it should have problems on system 7.5.1, or on 7.5.0 (but you shouldn't be running 7.5.0, it has many bugs). It has been tested on an SE, on a Classic II, and on a Power Macintosh 6100/60, so it would be surprising if there was a configuration it doesn't run on.
Known bugs in other software:
- when a window is closed in view picture, it doesn't release the colors it was using, so (amongst other things) icons in the finder go to black-and-white. Workaround: quit view picture.
- the following script doesn't work properly in AppleScript:
tell application "view picture"
activate
set the selection to some picture of document 1
get the contents of selection as reference
end tell
(the result it produces is not properly decoded by AppleScript; and you can't paste that result back into a script either.)
You need to use:
tell application "view picture"
activate
set the selection to some picture of document 1
get the bounds of the contents of selection
end tell
- The following script won't compile in AppleScript:
tell application "view picture"
activate
get every property of document 1
end tell
You need to substitute “«class prop»” for “property” to make it compile, but AppleScript decompiles the resulting script to the above.
- the following script doesn't do what you'd like:
tell application "view picture"
activate
get every property of document 1 as reference
end tell
(and doesn't compile, see above). It comes close, though; the partial result is what you probably wanted.
- SimpleText insists on showing the scripts above in color, and doesn't let you turn it off.
Revision History
Revision 1.1.0: The user interface for changing the compression method has changed; we now use the standard dialog box. The Apple Event for compression has added an extra depth parameter, and the quality parameter can now also be an number, for finer control. quit saving no now works. There is now an alternative picture for new documents when there are few colors available. Commands involving the clipboard ensure that view picture is the frontmost application (as otherwise it doesn’t have a clipboard to do anything with). Finally, if Easy Open is installed, view picture saved documents are called ‘View Picture picture’ (you may need to rebuild your desktop to ensure this).
Legal Notice and Licence
The author does not claim that View Picture is suitable for any purpose whatsoever. Because View Picture is provided free of charge, no warranty is provided. The author accepts no liability or responsibility of any sort for any loss or damage resulting from the use or operation of this software.
This documentation is Copyright 1995 Geoffrey Keating. All rights are reserved. You (the reader) are licensed to make and distribute unmodified copies of this documentation.
View Picture bears the following copyright notice and license:
“View Picture is Copyright 1994-1995 Geoffrey Keating. All rights are reserved.
You (the reader) are licensed to use this software and to make and distribute unmodified copies of this software, on condition that you not attempt to decompile, reverse engineer, or otherwise attempt to reduce this software to a human-readable form. By copying or using this software you are taken to agree to the terms of this license.”
Signature
This documentation, the View Picture application, and the Stuffit archive they are distributed in, are all signed by me using PowerTalk. The purpose of this is to give some reassurance that the program has not been tampered with in transit. To check a signature, choose “Get Info” in the Finder, and click on the icon next to the space for comments. If you don’t see an icon, either the signatures have been removed or you’re not running PowerTalk.